home *** CD-ROM | disk | FTP | other *** search
/ Clickx 47 / Clickx 47.iso / assets / software / sswitchxp152.exe / source / SpeedswitchXP / Speed.h < prev    next >
Encoding:
C/C++ Source or Header  |  2003-05-03  |  3.9 KB  |  97 lines

  1. /***************************************************************
  2. *
  3. * C file:   speed.h... for cpuinf32 DLL
  4. *
  5. *       This program has been developed by Intel Corporation.  
  6. *       You have Intel's permission to incorporate this code 
  7. *       into your product, royalty free.  Intel has various 
  8. *       intellectual property rights which it may assert under
  9. *       certain circumstances, such as if another manufacturer's
  10. *       processor mis-identifies itself as being "GenuineIntel"
  11. *       when the CPUID instruction is executed.
  12. *
  13. *       Intel specifically disclaims all warranties, express or
  14. *       implied, and all liability, including consequential and
  15. *       other indirect damages, for the use of this code, 
  16. *       including liability for infringement of any proprietary
  17. *       rights, and including the warranties of merchantability
  18. *       and fitness for a particular purpose.  Intel does not 
  19. *       assume any responsibility for any errors which may 
  20. *       appear in this code nor any responsibility to update it.
  21. *
  22. *  * Other brands and names are the property of their respective
  23. *    owners.
  24. *
  25. *  Copyright (c) 1995, Intel Corporation.  All rights reserved.
  26. ***************************************************************/
  27.  
  28. #ifndef speed_h
  29. #define speed_h
  30.  
  31.  
  32. // CONSTANT DEFINITIONS ////////////////////////////////////////
  33. #define CLONE_MASK      0x8000  // Mask to be 'OR'ed with proc-
  34. #define MAXCLOCKS       150     // Maximum number of cycles per
  35.                                 //   BSF instruction
  36. #define TSC_SUPPORT     0x00000010    // bit 4 in feature flags
  37.  
  38.     // ACCURACY AFFECTING CONSTANTS ////////////////////////////
  39. #define ITERATIONS      4000    // Number of times to repeat BSF
  40.                                 //   instruction in samplings.
  41.                                 //   Initially set to 4000.
  42.  
  43. #define MAX_TRIES       20      // Maximum number of samplings
  44.                                 //   to allow before giving up
  45.                                 //   and returning current 
  46.                                 //   average. Initially set to
  47.                                 //   20.
  48.     
  49. #define TOLERANCE       1       // Number of MHz to allow
  50.                                 //   samplings to deviate from
  51.                                 //   average of samplings.
  52.                                 //   Initially set to 2.
  53.  
  54. #define SAMPLINGS       10      // Number of BSF sequence 
  55.                                 //   samplings to make.
  56.                                 //   Initially set to 10.
  57.  
  58. // VARIABLE STRUCTURE DEFINITIONS //////////////////////////////
  59. struct FREQ_INFO
  60. {
  61.   unsigned long in_cycles;    // Internal clock cycles during test
  62.   unsigned long ex_ticks;     // Microseconds elapsed during test
  63.   unsigned long raw_freq;     // Raw frequency of CPU in MHz
  64.   unsigned long norm_freq;    // Normalized frequency of CPU in MHz
  65. };
  66.  
  67.  
  68. typedef unsigned short ushort;
  69. typedef unsigned long  ulong;
  70.  
  71. extern ushort sproc;
  72. extern DWORD sfeat;
  73.  
  74.  
  75. /***************************************************************
  76. * CpuSpeed() -- Return the raw clock rate of the host CPU.
  77. *
  78. * Inputs:
  79. *   clocks:     NULL: Use default value for number of cycles
  80. *                  per BSF instruction.
  81. *               Positive Integer: Use clocks value for number
  82. *                  of cycles per BSF instruction.
  83. *                 -1: Use CMos timer to calculate speed
  84. *                     (May not work for WinNT.
  85. *
  86. * Returns:
  87. *       If error then return all zeroes in FREQ_INFO structure
  88. *       Else return FREQ_INFO structure containing calculated 
  89. *       clock frequency, normalized clock frequency, number of 
  90. *       clock cycles during test sampling, and the number of 
  91. *       microseconds elapsed during the sampling.
  92. ***************************************************************/
  93. struct FREQ_INFO cpuspeed( int clocks );
  94.  
  95. #endif speed_h
  96.  
  97.